{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e4e21c38",
   "metadata": {},
   "source": [
    "# 人脸识别实践-宿舍智能识别门禁系统\n",
    "* 1.创建FaceSet  \n",
    "* 2.查询FaceSet  \n",
    "* 3.存入face_token数据    \n",
    "* 4.获取FaceSet信息数据  \n",
    "* 5.人脸搜索  \n",
    "* 6.人脸对比  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51c5519f",
   "metadata": {},
   "source": [
    "## 1.创建faceset"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7f07d00",
   "metadata": {},
   "source": [
    "* 描述    \n",
    "> 1.创建一个人脸的集合 FaceSet，用于存储人脸标识 face_token。一个 FaceSet 能够存储10000个 face_token。  \n",
    "> 2.试用API Key可以创建1000个FaceSet，正式API Key可以创建10000个FaceSet  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "06f9857f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "02444855",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>是否必选</th>\n",
       "      <th>参数名</th>\n",
       "      <th>类型</th>\n",
       "      <th>参数说明</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>必选</td>\n",
       "      <td>api_key</td>\n",
       "      <td>String</td>\n",
       "      <td>调用此 API 的 API Key</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>必选</td>\n",
       "      <td>api_secret</td>\n",
       "      <td>String</td>\n",
       "      <td>调用此 API 的 API Secret</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>可选</td>\n",
       "      <td>display_name</td>\n",
       "      <td>String</td>\n",
       "      <td>人脸集合的名字，最长256个字符，不能包括字符^@,&amp;=*'\"</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>可选</td>\n",
       "      <td>outer_id</td>\n",
       "      <td>String</td>\n",
       "      <td>账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>可选</td>\n",
       "      <td>tags</td>\n",
       "      <td>String</td>\n",
       "      <td>FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长255个字符，多个...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>可选</td>\n",
       "      <td>face_tokens</td>\n",
       "      <td>String</td>\n",
       "      <td>人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_t...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>可选</td>\n",
       "      <td>user_data</td>\n",
       "      <td>String</td>\n",
       "      <td>自定义用户信息，不大于16 KB，不能包括字符^@,&amp;=*'\"</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>可选</td>\n",
       "      <td>force_merge</td>\n",
       "      <td>Int</td>\n",
       "      <td>在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_to...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  是否必选           参数名      类型  \\\n",
       "0   必选       api_key  String   \n",
       "1   必选    api_secret  String   \n",
       "2   可选  display_name  String   \n",
       "3   可选      outer_id  String   \n",
       "4   可选          tags  String   \n",
       "5   可选   face_tokens  String   \n",
       "6   可选     user_data  String   \n",
       "7   可选   force_merge     Int   \n",
       "\n",
       "                                                参数说明  \n",
       "0                                  调用此 API 的 API Key  \n",
       "1                               调用此 API 的 API Secret  \n",
       "2                    人脸集合的名字，最长256个字符，不能包括字符^@,&=*'\"  \n",
       "3  账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255...  \n",
       "4  FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长255个字符，多个...  \n",
       "5  人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_t...  \n",
       "6                    自定义用户信息，不大于16 KB，不能包括字符^@,&=*'\"  \n",
       "7  在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_to...  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"\"\"<div class=\"table-wrap\"><table class=\"wrapped confluenceTable\"><colgroup><col><col><col><col></colgroup><tbody><tr><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">是否必选</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">参数名</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">类型</span></p></th><th class=\"confluenceTh\"><p><span style=\"color: rgb(0,0,0);\">参数说明</span></p></th></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">必选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">api_key</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">调用此 API 的 API Key</span></p></td></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">必选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">api_secret</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">调用此 API 的 API Secret</span></p></td></tr><tr><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">display_name</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">人脸集合的名字，最长<span class=\"inline-comment-marker\" data-ref=\"9f098728-ac30-41a2-aab6-05b79f8a7d2e\">256</span>个字符，不能包括字符^@,&=*'\"</span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">outer_id</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">账号下全局唯一的 FaceSet 自定义标识，可以用来管理 FaceSet 对象。最长255个字符，<span class=\"inline-comment-marker\" data-ref=\"63fc0fd1-cd44-4256-bab5-971a939d66e2\"><span class=\"inline-comment-marker\" data-ref=\"183dcb11-c22c-47f4-aa9c-2ba6f3c8210c\">不能包括字符^@,&=*'\"</span></span></span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">tags</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">FaceSet 自定义标签组成的字符串，用来对 FaceSet 分组。最长<span class=\"inline-comment-marker\" data-ref=\"1be760b6-f20d-4ff3-a086-b7f763abd84d\">255</span>个字符，多个 tag 用逗号分隔，每个 tag 不能包括字符^@,&=*'\"</span></td></tr><tr><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">可选</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">face_tokens</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">String</span></p></td><td class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">人脸标识 face_token，可以是一个或者多个，用逗号分隔。最多不超过5个 face_token</span></p></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">user_data</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">String</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">自定义用户信息，不大于<span class=\"inline-comment-marker\" data-ref=\"f9edadb1-691d-4d80-933e-909096780f61\">16 KB，不能包括字符^@,&=*'\"</span></span></td></tr><tr><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">可选</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">force_merge</span></td><td colspan=\"1\" class=\"confluenceTd\"><span style=\"color: rgb(0,0,0);\">Int</span></td><td colspan=\"1\" class=\"confluenceTd\"><p><span style=\"color: rgb(0,0,0);\">在传入 outer_id 的情况下，如果 outer_id 已经存在，是否将 face_token 加入已经存在的 FaceSet 中</span></p><p><span style=\"color: rgb(0,0,0);\">0：不将 face_tokens 加入已存在的 FaceSet 中，直接返回 FACESET_EXIST 错误</span></p><p><span style=\"color: rgb(0,0,0);\">1：将 face_tokens 加入已存在的 FaceSet 中</span></p><p><span style=\"color: rgb(0,0,0);\">默认值为0</span></p></td></tr></tbody></table></div>\"\"\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "109865d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.导入需要的requests模块\n",
    "import requests\n",
    "\n",
    "# 2.准备api的接口身份\n",
    "\n",
    "API_Key = \"AXr0X-fVLzYtJg-Yo13sIqOnA08EUcA1\"\n",
    "API_Secret = \"FgzgKXqhaxO6rcQX7m2kCqkdjBdvBQLg\"\n",
    "\n",
    "# 3.准备base URL(face detect)\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/create\"\n",
    "\n",
    "# 4.请求方法：POST\n",
    "\n",
    "# 5.准备请求参数：payload（酬载）\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    \"image_url\":\"https://uploadfile.bizhizu.cn/up/38/f4/21/38f421bb04707d4d5cbe25965158262f.jpg\",\n",
    "#    \"return_landmark\":1,\n",
    "    \"return_attributes\":\"gender,age,smiling\"\n",
    "\n",
    "}\n",
    "# 6.请求数据\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "90341e96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': '539a7717c635255aae532a62c7c8aeff',\n",
       " 'time_used': 179,\n",
       " 'face_count': 0,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1648618019,60b66bbb-cc5a-4084-80ba-dbd5f51e00ea',\n",
       " 'outer_id': '',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8e2de8ca",
   "metadata": {},
   "source": [
    "## 2.查询faceset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4808143a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.导入需要的requests模块\n",
    "import requests\n",
    "\n",
    "# 2.准备api的接口身份\n",
    "\n",
    "API_Key = \"AXr0X-fVLzYtJg-Yo13sIqOnA08EUcA1\"\n",
    "API_Secret = \"FgzgKXqhaxO6rcQX7m2kCqkdjBdvBQLg\"\n",
    "\n",
    "# 3.准备base URL(face detect)\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/getfacesets\"\n",
    "\n",
    "# 4.请求方法：POST\n",
    "\n",
    "# 5.准备请求参数：payload（酬载）\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    \"image_url\":\"https://uploadfile.bizhizu.cn/up/38/f4/21/38f421bb04707d4d5cbe25965158262f.jpg\",\n",
    "\n",
    "}\n",
    "# 6.请求数据\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "772b6621",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 73,\n",
       " 'facesets': [{'faceset_token': 'f2928b5a0cb3ac9fbae70daf2acdeee0',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'fb5a0d8c59983a6963d35eb64222e105',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'c53bfe56eca694f968c222d2bb45f44e',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': 'c4cdb368b91cb7b8624b0e7cb04e108e',\n",
       "   'outer_id': 'nfusd00',\n",
       "   'display_name': '广州南方学院0东宿舍楼',\n",
       "   'tags': ''},\n",
       "  {'faceset_token': '539a7717c635255aae532a62c7c8aeff',\n",
       "   'outer_id': '',\n",
       "   'display_name': '',\n",
       "   'tags': ''}],\n",
       " 'request_id': '1648618031,7e2b7a67-6364-4237-b9ef-b5af1600bbad'}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7f42b16c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'539a7717c635255aae532a62c7c8aeff'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "faceset_token=r.json()['facesets'][-1]['faceset_token']\n",
    "faceset_token"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35c73e97",
   "metadata": {},
   "source": [
    "## 更新人脸库信息 API\n",
    "* 描述\n",
    "> 更新一个人脸集合的属性\n",
    "\n",
    "* 调用URL\n",
    "> https://api-cn.faceplusplus.com/facepp/v3/faceset/update\n",
    "\n",
    "* 调用方法\n",
    "> POST"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8ccc5d0f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.导入需要的requests模块\n",
    "import requests\n",
    "\n",
    "# 2.准备api的接口身份\n",
    "\n",
    "API_Key = \"AXr0X-fVLzYtJg-Yo13sIqOnA08EUcA1\"\n",
    "API_Secret = \"FgzgKXqhaxO6rcQX7m2kCqkdjBdvBQLg\"\n",
    "\n",
    "# 3.准备base URL(face detect)\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/update\"\n",
    "\n",
    "# 4.请求方法：POST\n",
    "\n",
    "# 5.准备请求参数：payload（酬载）\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    'faceset_token':faceset_token,\n",
    "    'display_name':'广州南方学院0东宿舍楼',\n",
    "    'new_outer_id':'nfusd00',\n",
    "    'user_data':'6层，满员，女生宿舍，460同学，均已录入facetoken'\n",
    "}\n",
    "# 6.请求数据\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "caaeda0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 79,\n",
       " 'error_message': 'NEW_OUTER_ID_EXIST',\n",
       " 'request_id': '1648618067,23651d5d-b90b-4c8c-b287-ff25ac4d7777'}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0429575a",
   "metadata": {},
   "source": [
    "## 检查数据集合信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e298b98c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.导入需要的requests模块\n",
    "import requests\n",
    "\n",
    "# 2.准备api的接口身份\n",
    "\n",
    "API_Key = \"AXr0X-fVLzYtJg-Yo13sIqOnA08EUcA1\"\n",
    "API_Secret = \"FgzgKXqhaxO6rcQX7m2kCqkdjBdvBQLg\"\n",
    "\n",
    "# 3.准备base URL(face detect)\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail\"\n",
    "\n",
    "# 4.请求方法：POST\n",
    "\n",
    "# 5.准备请求参数：payload（酬载）\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    'outer_id':'nfusd00'\n",
    "\n",
    "}\n",
    "# 6.请求数据\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "135497cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'c4cdb368b91cb7b8624b0e7cb04e108e',\n",
       " 'tags': '',\n",
       " 'time_used': 95,\n",
       " 'user_data': '6层，满员，女生宿舍，460同学，均已录入facetoken',\n",
       " 'display_name': '广州南方学院0东宿舍楼',\n",
       " 'face_tokens': [],\n",
       " 'face_count': 0,\n",
       " 'request_id': '1648618075,af133f18-510d-4304-a0fd-9971ca558d86',\n",
       " 'outer_id': 'nfusd00'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "65e75b5a",
   "metadata": {},
   "source": [
    "## 5.人脸检测，获取人脸token"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "dc9fd8ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "import detect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "130f202b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module detect:\n",
      "\n",
      "NAME\n",
      "    detect\n",
      "\n",
      "FUNCTIONS\n",
      "    face_detect(API_key, API_sercret, image_path)\n",
      "        该函数为调用face++ face_detect接口\n",
      "\n",
      "FILE\n",
      "    e:\\api-artificial-intelligence\\week04\\detect.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(detect)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "8118c115",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648618083,29b7353a-8219-49a9-866d-bf659addb86b',\n",
       " 'time_used': 105,\n",
       " 'faces': [{'face_token': 'de024d22e4a6ae886196e63a131c0c7f',\n",
       "   'face_rectangle': {'top': 180, 'left': 102, 'width': 171, 'height': 171}}],\n",
       " 'image_id': 'L6pns8Z7qHuOIyRC7xmKhQ==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "detect.face_detect(API_Key,API_Secret,'yifei.jpg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "766eb46f",
   "metadata": {},
   "source": [
    "## 6.人脸存放"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "fc168423",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1.导入需要的requests模块\n",
    "import requests\n",
    "\n",
    "# 2.准备api的接口身份\n",
    "\n",
    "API_Key = \"AXr0X-fVLzYtJg-Yo13sIqOnA08EUcA1\"\n",
    "API_Secret = \"FgzgKXqhaxO6rcQX7m2kCqkdjBdvBQLg\"\n",
    "\n",
    "# 3.准备base URL(face detect)\n",
    "base_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/addface\"\n",
    "\n",
    "# 4.请求方法：POST\n",
    "\n",
    "# 5.准备请求参数：payload（酬载）\n",
    "payload = {\n",
    "    \"api_key\":API_Key,\n",
    "    \"api_secret\":API_Secret,\n",
    "    'outer_id':'nfusd00'\n",
    "\n",
    "}\n",
    "# 6.请求数据\n",
    "\n",
    "r = requests.post(base_url,payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "5c90c4b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 76,\n",
       " 'error_message': 'MISSING_ARGUMENTS: face_tokens',\n",
       " 'request_id': '1648618203,0bd706e7-2c9c-45b7-9294-3e7e82dd8899'}"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e9ea973",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
